﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using AjaxControlToolkit;

public partial class Front_NoDealExist : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                BindCity();

            }
            catch
            {
            }
        }
    }
    private void BindCity()
    {

        var deal = new DealesDataContext();
        var query = deal.City_ReturnForSubscribe();
        DLCity.DataSource = query;
        DLCity.DataBind();
    }
    protected void DLCity_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Cookies.Clear();
        Response.Cookies["CityID"].Expires = DateTime.Now.AddYears(-30);
        Response.Cookies["CityName"].Expires = DateTime.Now.AddYears(-30);
        Response.Cookies["CityID"].Value = DLCity.DataKeys[DLCity.SelectedItem.ItemIndex].ToString();
        Response.Cookies["CityID"].Expires = DateTime.Now.AddDays(30);
        Response.Cookies["CityName"].Value = ((LinkButton)DLCity.Items[DLCity.SelectedIndex].FindControl("LinkButton1")).Text;
        Response.Cookies["CityName"].Expires = DateTime.Now.AddDays(30);
        string CityID;
        string DealID = "0";
        CityID = DLCity.DataKeys[DLCity.SelectedItem.ItemIndex].ToString();
        var sub = new DealesDataContext();
        var getDealID = sub.Select_DealByCityIDNew(Convert.ToInt32(CityID));
        foreach (var item in getDealID)
        {
            DealID = item.DealID.ToString();
        }

        Response.Redirect("~/Default.aspx?DealID=" + DealID);
    }
}
